package at.fpmedv.eclipse.helma.core;

import java.util.Comparator;

import at.fpmedv.eclipse.helma.util.ResourceContainer;

import helma.framework.repository.Resource;

/**
 * represents a skin in the tree view
 * 
 * @author fpm
 * 
 */
public class SkinTreeObject implements ITreeObject {
	private Resource skin;
	private HelmaPrototypeTreeObject parent;

	public SkinTreeObject(Resource skinResource,
			HelmaPrototypeTreeObject parent) {
		skin = skinResource;
		this.parent = parent;
	}

	public Object getAdapter(Class key) {
		return null;
	}

	public String getName() {
		return skin.getShortName();
	}

	public String getRawName() {
		return getName();
	}

	public ITreeParent getParent() {
		return parent;
	}

	public String toString() {
		return getName();
	}

	public ResourceContainer getResource() {
		return new ResourceContainer(skin, 0);
	}

	public int compare(ITreeObject element, Comparator comparator) {
		// sort by name
		if (element instanceof SkinTreeObject)
			return comparator.compare(this.getName(), element.getName());
		// smaller than everything else
		return 1;
	}
}
